<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 定义一个含有30个整型元素的数组，按顺序分别赋予从2开始的偶数；然后按顺序每五个数求出一个平均值，放在另一个数组中并输出。试编程。
        // var arr = [2, 4, 6, 8, ..., 60]
        // 结果是一个新的数组
        // [6, 16, 26, 36, 46, 56]

        var arr = [];
        for (var i = 1; i <= 60; i++) {
            if (i % 2 == 0) {
                arr.push(i);
            }
        }
        console.log(arr);
        var all = 0;
        var newarr = [];
        for (var j = 0; j < arr.length; j++) {
            all += arr[j];
            if ((j + 1) % 5 == 0) {
                var num = all / 5;
                console.log(num);
                newarr.push(num);
                all = 0;
            }
        }
        console.log(newarr);
    </script>
</body>

</html>